# from moviepy.editor import VideoFileClip
import moviepy
import file_dir.file_list as file_list
def process_video(input_path, output_path):
    try:
        clip = moviepy.VideoFileClip(input_path)
        print(f"Video duration: {clip.duration} seconds")
        # 这里可以添加更多的视频处理逻辑
        clip.write_videofile(output_path, codec='libx264')
    except OSError as e:
        print(f"Error reading video: {e}")

def get_video_duration(filepath):
    clip = moviepy.VideoFileClip(filepath)
    duration = clip.duration
    clip.close()
    return duration


def seconds_to_time(seconds):
    # SecToConvert = 56000

    MinutesGet, SecondsGet = divmod(seconds, 60)
    HoursGet, MinutesGet = divmod(MinutesGet, 60)

    # 省略小数点
    HoursGet = int(HoursGet)
    MinutesGet = int(MinutesGet)
    SecondsGet = int(SecondsGet)

    return HoursGet, MinutesGet, SecondsGet


if __name__ == '__main__':
    # 输入和输出文件路径
    # input_video = r'I:\003_Material\Data\Porn\短视频\K 세로룩북) Ai 실사 룩북🤍 레전드 몸매 란제리 언더웨어 룩북 bikini underwear Lookbook 모델 룩북 직캠 Lingerie Try On.mp4'
    # output_video = r'D:\data\K 세로룩북) Ai 실사 룩북🤍 레전드 몸매 란제리 언더웨어 룩북 bikini underwear Lookbook 모델 룩북 직캠 Lingerie Try On.mp4'
    #
    # process_video(input_video, output_video)
    path = r"E:\Enterainment\Downloads\TEA24080807\『多人运动✅硬核重磅』一个人挑战5个，老公说让我一个人挑战8个，你体验过多人运动的刺激吗？嘴里一根JJ手机还有一根"
    for item in file_list.get_all_files_by_type(path, '.mp4'):
        print(item[item.rfind("\\")+1:])
        hour, minute, second = seconds_to_time(get_video_duration(item))
        time_str = str(hour) + ":" + str(minute) + ":" + str(second)
        print(time_str.replace(" ",""))
